<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:mo="https://gitee.com/aun/Timo">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
    <link rel="stylesheet" th:href="@{/lib/zTree_v3/css/zTreeStyle/zTreeStyle.css}" type="text/css">
</head>
<body class="timo-layout-page">
<form id="searchForm" name="searchForm" class="layui-form" action="/mains/orders/index">
    <input type="hidden" id="pageNum" name="pageNum" th:value="${page.pageNum}"/>
    <input type="hidden" id="pageSize" name="pageSize" th:value="${page.pageSize}"/>
</form>
    <div class="layui-card">
        <div class="layui-card-header timo-card-header">
            <span><i class="fa fa-bars"></i> 订单管理</span>
            <i class="layui-icon layui-icon-refresh refresh-btn"></i>
            <a th:href="@{/mains/order/export}"><i class="fa fa-download"></i></a>
        </div>
        <div class="layui-card-body">
            <div class="layui-row timo-card-screen put-row">
                <div class="pull-left layui-form-pane timo-search-box">
                    <div class="layui-inline">
                        <label class="layui-form-label">订单号</label>
                        <div class="layui-input-block">
                            <input type="text" name="orderCodes"  placeholder="请输入订单号" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn timo-search-btn">
                            <i class="fa fa-search"></i>
                        </button>
                    </div>
                </div>
            </div>

            <div class="timo-table-wrap">
                <table class="layui-table timo-table">
                    <thead>
                    <tr>
                        <th class="timo-table-checkbox">
                            <label class="timo-checkbox"><input type="checkbox">
                                <i class="layui-icon layui-icon-ok"></i></label>
                        </th>
                        <th>下单时间</th>
                        <th>商品名称</th>
                        <!--<th>订单号</th>-->
                        <th>联系电话</th>
                        <th>联系人</th>
                        <th>缩略图</th>
                        <th> 花费金额</th>
                        <th> 消耗美颜值</th>
                        <th> 剩余美颜值</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="item:${list}">
                        <td><label class="timo-checkbox"><input type="checkbox" th:value="${item.id}">
                            <i class="layui-icon layui-icon-ok"></i></label></td>
                        <td th:text="${item.exTime}"></td>
                        <td th:text="${item.productName}"></td>
                        <!--<td th:text="${item.orderCodes}"></td>-->
                        <td th:text="${item.mobile}"></td>
                        <td th:text="${item.username}"></td>
                        <td>
                            <a class="open-popup"  style="cursor: pointer" th:attr="data-url=@{${item.imageUrl}}" data-size="600,570" href="#">预览</a>
                        </td>
                        <!--<td th:text="${item.address}"></td>-->
                        <td th:text="${item.money}"></td>
                        <td th:text="${item.points}"></td>
                        <td th:text="${item.surpluspoints}"></td>
                        <td th:text="${item.status}"></td>
                        <td>
                            <!--<a class="open-popup" data-title="编辑订单" th:attr="data-url=@{'/mains/order/edit/'+${item.id}}"  data-size="600,570" href="#">编辑</a>-->
                            <a class="open-popup" data-title="详细信息" th:attr="data-url=@{'/mains/orders/detail/'+${item.id}}"  data-size="800,600" href="#">详细</a>
                            <th:block th:if="${item.tradeState==0}">
                                <button type="button" th:attr="data-ii=@{${item.id}}"
                                        class="layui-btn layui-btn-normal layui-btn-xs" onclick="verifyOrder(this)">订单对账
                                </button>
                            </th:block>
                           <!-- 0 待支付 1待发货 2已发货 3已完成 4 已取消 5支付失败6退款中7已退款8售后审核中9审核通过10审核未通过11待体验12待取件-->
                            <th:block th:if="${item.tradeType == 0}">
                                <a class="open-popup" data-title="配送信息" th:if="${item.states ==0 && (item.tradeState == null ||item.tradeState == 1 ||item.tradeState == -1)}" th:attr="data-url=@{'/mains/orders/express/'+${item.id}}"  data-size="600,450" href="#">配送</a>
                            </th:block>
                            <th:block th:if="${item.tradeType == 1 || item.tradeType == 2 }">
                                <a class="open-popup" data-title="配送信息" th:if="${item.states ==0 && item.tradeState == 1}" th:attr="data-url=@{'/mains/orders/express/'+${item.id}}"  data-size="600,450" href="#">配送</a>
                            </th:block>
                            <a class="open-popup" data-title="订单管理" th:attr="data-url=@{'/mains/orders/administration/'+${item.id}}"  data-size="650,400" href="#">订单管理</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <!--<div th:replace="/common/fragmentSelf :: page"></div>-->
            <div id="pager" ></div>
        </div>
    </div>
<script th:replace="/common/template :: script"></script>
<script type="text/javascript" th:src="@{/js/plugins/jquery-3.3.1.min.js}"></script>
<script type="text/javascript" th:src="@{/lib/zTree_v3/js/jquery.ztree.core.min.js}"></script>
<script type="text/javascript" th:src="@{/js/timoTree.js}"></script>
<script type="text/javascript" th:inline="javascript">
    function verifyOrder(e) {
        var attr = $(e).attr("data-ii");
        $.ajax({
            type: "get",
            url:"/mains/orders/verifyOrder/"+attr,
            success:function (result) {
                layer.tips('订单对账完成', e);
            }
        })
        // layer.tips('复制成功', e);
    }
    layui.use(['laypage', 'layer'],function () {
        var laypage = layui.laypage,layer = layui.layer;
        laypage.render({
            elem: 'pager'
            ,curr: [[${page.pageNum}]]
            ,count: [[${page.total}]]
            ,limit: [[${page.pageSize}]]
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            ,jump: function(obj,first){
                //得到了当前页，用于向服务端请求对应数据
                var curr = obj.curr;
                var limit = obj.limit;
                $("#pageSize").val(limit);
                $("#pageNum").val(curr);
                if (!first) {
                    $("#searchForm").submit();
                }
            }
        });
    })

</script>
</body>
</html>
